<template>
  <rt-view>
    <rt-content>
      <div class="main-conetnt">
        <div class="top-content">
          <img :src="img" @error="showErrorPic($event)"/>
        </div>
        <div class="middle-conetnt">
          <div class="activity-content">
            <div class="title-content">
              {{ articleForm.name }}
            </div>
            <div class="class-tag">
              <span>{{ articleForm.bbs_article_typeidname }}</span>
            </div>
            <div class="message">
              <img src="../../assets/icons/svgs/look.svg"  @error="showErrorPic($event)" />{{
                countForm.openCount
              }}
            </div>
            <div class="content" v-html="articleForm.content"></div>
          </div>
        </div>
      </div>
    </rt-content>
  </rt-view>
</template>

<script>
export default {
  data() {
    return {
      id: '',
      showAlert: false,
      articleForm: {
        avatar: '',
        bbs_article_typeidname: '',
        bbs_articleid: '',
        name: ''
      },
      countForm: {
        commentCount: 0,
        favoriteCount: 0,
        openCount: 0,
        postLikeCount: 0
      },
      img: '',
      imgs: []
    };
  },
  mounted() {
    this.id = this.$route.query.id;
    this.name = this.$route.query.name;
    if (this.id != null && this.id !== '') {
            var param = {
        object_id: this.id,
        object_name: this.name
      };
      rt.post(`/api/bbs/openedlog/saveopenlog/article`, param)
        .then(res => {
        })
        .catch(error => {
          rt.showErrorToast(error);
        });
      this.getArticleById();
      this.getArticleStatistics();
    }
  },
  computed: {
  },
  methods: {
    getArticleById() {
      rt.get(`api/bbs/article/detail/${this.id}`)
        .then(res => {
          this.img = rt.showRemotePic(res.avatar);
          this.imgs.push(this.img);
          //   this.form = res;
          this.articleForm = res;
        })
        .catch(error => {
          rt.showErrorToast(error);
        });
    },
    getArticleStatistics() {
      rt.get(`api/bbs/article/getstatistics/${this.id}`)
        .then(res => {
          this.countForm = res;
        })
        .catch(error => {
          rt.showErrorToast(error);
        });
    },
    showErrorPic(e){
      e.target.src = require('@/assets/imgs/no-pictures.svg');
      e.target.onerror = null; //防止闪图
    }
  }
};
</script>
<style lang="less" scoped>
@deepselecter: ~'>>>';
.main-conetnt {
  .top-content {
    z-index: -1;
    padding: 0;
    img {
      z-index: 1;
    }
  }
  .content {
    color: #555555;
    margin: 10px 5px 0px 5px;
    line-height: 2em;
    p {
      text-indent: 27pt;
    }
  }
  .comment {
    margin-top: 12px;
    margin-bottom: 8px;
    border-bottom: 1px #E8E8E8 solid;
    padding-bottom: 15px;
    color: #222222;
    font-family: Microsoft YaHei;
    font-weight: bold;
  }
  .comment-list {
    clear: both;
    margin-top: 5px;
    padding-top: 10px;
    .img {
      width: 50px;
      height: 50px;
      float: left;
    }
    .title {
      margin-left: 50px;
      height: 100%;
      .detail {
        height: 30px;
        padding-top: 3px;
        color: #555555;
        span {
          font-size: 14px;
          color: #888888;
        }
        b {
          float: right;
          margin-right: 1%;
        }
      }
      .c-content {
        border-bottom: 0.5pt #f0f0f0 solid;
        padding-bottom: 10px;
        color: #222222;
        margin-top: 5px;
        line-height: 24pt;
        padding-right: 21px;
      }
    }
  }
  .c-comment-list {
    margin-top: 5px;
    margin-left: 10%;
    .img {
      margin-left: 12px;
      margin-top: 5px;
      clear: both;
      float: left;
    }
    .title {
      margin-left: 50px;
      height: 100%;
      .detail {
        height: 30px;
        padding-top: 3px;
        color: #555555;
        span {
          font-size: 14px;
          color: #888888;
        }
        b {
          float: right;
          margin-right: 1%;
        }
      }
      .c-content {
        border-bottom: 0.5pt #f0f0f0 solid;
        padding-bottom: 10px;
        color: #222222;
        margin-top: 5px;
        line-height: 24pt;
        padding-right: 20px;
        span span {
          font-family: normal;
          color: #53a4fc;
        }
      }
    }
  }
  .noContent {
    margin: 10px auto;
    text-align: center;
    color: #cccccc;
    display: none;
  }
  .middle-conetnt {
    z-index: 1;
    position: relative;
    margin-top: -35px;
    padding: 15px 15px 15px 15px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.2), 0 1px 2px 0 rgba(0, 0, 0, 0.1);
    .activity-content {
      .title-content {
        font-weight: bold;
        padding-bottom: 10px;
      }
      .name-content {
        padding: 10px 0;
        .name-sty {
          color: blue;
          display: inline-block;
        }
        .show-sty {
          display: inline-block;
        }
      }
      .time-content {
        padding: 10px 0;
        .img-svg {
          width: 23px;
          height: 23px;
          float: left;
          margin-right: 5px;
        }
      }
      .sub-title {
        font-weight: bolder;
        padding: 20px 0;
      }
    }
  }
  .buttom-content {
    margin-bottom: 20px;
    padding-bottom: 30px;
  }
  .buttom-button {
    position: absolute;
    text-align: center;
    bottom: 0;
    margin: 10px 0;
    width: 92%;
    height: 45px;
    line-height: 45px;
    border-radius: 5px;
    left: 50%;
    padding-top: 100px;
    transform: translateX(-50%);
  }

  & @{deepselecter} .rt-btn {
    margin-right: 13px;
  }
}
</style>
<style lang="less" scoped>
/deep/ .input-area.is-top .input-label {
  padding-top: 7px;
}
/deep/ .rt-readonly .rt-text-readonly {
  text-align: left;
  color: #888;
  font-weight: 400;
}
/deep/ .input-area.is-top .input-wrapper {
  padding: 5px 0 5px 0;
}
.footer {
  background: #ffffff;
  display: flex;
  align-items: center;
  .footer-comment {
    flex: 1;
    margin: 6px 5px 6px 10px;
    height: 32px;
    line-height: 32px;
    background: rgba(180, 189, 207, 0.15);
    color: #cccccc;
    border-radius: 16px;
    padding-left: 15px;
  }
  .footer-like {
    text-align: center;
    color: #53a4fc;
    padding-right: 10px;
    img {
      display: inline-block;
      width: 20px;
      padding-left: 5px;
      padding-right: 5px;
    }
  }
  .footer-dislike {
    color: #888888;
  }
  .footer-liked {
    color: #53a4fc;
  }
  rt-icon {
    color: red;
    background: red;
  }
}
.rt-btn-icon {
  /deep/ .rt-button-icon > svg use {
    fill: #53a4fc !important;
  }
}
.main-conetnt {
  background: #ffffff;
}
.class-tag span {
  padding: 1px 10px 1px 10px;
  margin-bottom: 10px;
  display: inline-block;
  background: #e6f1fd;
  color: #53a4fc;
  border-radius: 5px;
  margin-bottom: 10px;
}
.message {
  color: #888888;
  padding-bottom: 10px;
  border-bottom: 1px #f0f0f0 solid;
  img {
    height: 12px;
    display: inline-block;
    width: 18px;
    padding-right: 5px;
  }
}
.share-open{
  height: 60px;
  padding: 20px 50px;
  display: flex;
  .share-weixin{
    float: left;
    margin-left: 20%;
    width: 50%;
    img{
      margin-left: 3px;
    }
  }
  .share-friend{
    width: 50%;
    img{
      margin-left: 10px;
    }
  }
  .img-svg{
    width: 25px;
    height: 25px;
  }
}
</style>
